package org.lq.view.mian;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Image;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import org.lq.er.entity.Exam_information;
import org.lq.er.entity.Student;
import org.lq.er.service.impl.Exam_informationServiceImpl;
import org.lq.er.view.Information.V_Apply;
import org.lq.er.view.Information.V_checkApply;
import org.lq.er.view.admission.Admission;
import org.lq.er.view.announcement.AnnouncementAdd;
import org.lq.er.view.announcement.User_announcement;
import org.lq.er.view.login.V_login;
import org.lq.er.view.register.V_register;
import org.lq.er.view.score.ER_score_check;

import java.awt.Color;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.SwingConstants;
import javax.swing.JScrollPane;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import java.awt.SystemColor;
import java.awt.Label;

public class V_Student extends JFrame {

	private JPanel contentPane;
	static Student student;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					V_Student frame = new V_Student(student);
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public V_Student(Student s) {
		Image image = java.awt.Toolkit.getDefaultToolkit().getImage("image/index.jpg");
		this.setIconImage(image);
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setResizable(false);
		setBounds(100, 100, 917, 593);
		setLocationRelativeTo(null);
		contentPane = new JPanel();
		contentPane.setBackground(Color.WHITE);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JButton btnNewButton_1 = new JButton("进入报名");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
//				dispose();
				V_Apply apply = new V_Apply();
				apply.setVisible(true);
			}
		});
		btnNewButton_1.setBackground(SystemColor.controlHighlight);
		btnNewButton_1.setHorizontalAlignment(SwingConstants.LEFT);
		btnNewButton_1.setBounds(71, 181, 195, 59);
		btnNewButton_1.setBorder(null);
		contentPane.add(btnNewButton_1);
		
		JButton btnNewButton_2 = new JButton("查看报名信息");
		btnNewButton_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
//				dispose();
				V_checkApply checkApply = new V_checkApply();
				checkApply.setVisible(true);
			}
		});
		btnNewButton_2.setBackground(SystemColor.controlHighlight);
		btnNewButton_2.setHorizontalAlignment(SwingConstants.LEFT);
		btnNewButton_2.setBounds(71, 258, 195, 59);
		btnNewButton_2.setBorder(null);
		contentPane.add(btnNewButton_2);
		
		JButton btnNewButton_3 = new JButton("下载准考证");
		btnNewButton_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Exam_informationServiceImpl eisi = new Exam_informationServiceImpl();
				Exam_information ei = eisi.getByStu_Id(s.getCard_id());
				if(ei.getStatus_pay() == 1) {
					new Admission(s);
				}else if(ei.getStatus_check() == 1 && ei.getStatus_pay() == 0){
					JOptionPane.showMessageDialog(contentPane, "未交费", "提示", JOptionPane.INFORMATION_MESSAGE);
				}else {
					JOptionPane.showMessageDialog(contentPane, "未报名", "提示", JOptionPane.INFORMATION_MESSAGE);
				}
			}
		});
		btnNewButton_3.setBackground(SystemColor.controlHighlight);
		btnNewButton_3.setHorizontalAlignment(SwingConstants.LEFT);
		btnNewButton_3.setBounds(71, 344, 195, 59);
		btnNewButton_3.setBorder(null);
		contentPane.add(btnNewButton_3);
		
		JButton btnNewButton_4 = new JButton("查看成绩");
		btnNewButton_4.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
//				dispose();
				ER_score_check check = new ER_score_check();
				check.setVisible(true);
			}
		});
		btnNewButton_4.setBackground(SystemColor.controlHighlight);
		btnNewButton_4.setHorizontalAlignment(SwingConstants.LEFT);
		btnNewButton_4.setBounds(71, 426, 195, 59);
		btnNewButton_4.setBorder(null);
		contentPane.add(btnNewButton_4);
		
		ImageIcon image1 = new ImageIcon("image/bg.png");
		JLabel panel = new JLabel(image1);
		panel.setBounds(0, 0, 904, 61);
		contentPane.add(panel);
		
		ImageIcon image2 = new ImageIcon("image/progess.png");
		image2.setImage(image2.getImage().getScaledInstance(904, 61,Image.SCALE_DEFAULT));
		JLabel panel_1 = new JLabel(image2);
		panel_1.setBackground(new Color(208,32,144));
		panel_1.setBounds(0, 62, 904, 61);
		contentPane.add(panel_1);
		
		JPanel annoucement = new User_announcement();
		annoucement.setSize(434, 303);
		annoucement.setLocation(345, 181);
		annoucement.setVisible(true);
		contentPane.add(annoucement);	
	
		JLabel label = new JLabel("你好,"+s.getName());
		label.setBounds(769, 129, 149, 43);
		contentPane.add(label);
			
		
		
		
		
		}
}
